package cn.edu.hznu.coursework.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.edu.hznu.coursework.entity.Course;
import cn.edu.hznu.coursework.entity.Student;
import cn.edu.hznu.coursework.entity.Teacher;

public interface CourseRepository extends JpaRepository<Course, Integer> {

	public List<Course> findByCourseName(String name);
	
	public List<Course> findByTeacher(Teacher teacher);
	
	@Query("SELECT c FROM Course c INNER JOIN c.students s WHERE s IN (:students)")
	public List<Course> findByStudents(@Param("students") List<Student> students);
	
	public Course findByCourseNameAndCourseNo(String courseName, char courseNo);
}
